import React from 'react';
import Home from "./components/Home";
import My from "./components/My";
import One from "./components/One";
import Two from "./components/Two";
import Three from "./components/Three";
class App extends React.Component{
    state = {
        isError:false,
        isShow:true
    }
    static getDerivedStateFromError(){
        console.log(1111)
        return {
            isError:true
        }
    }
    componentDidCatch(error, errorInfo) {
        // 通过ajax调用接口，告知服务端发生异常
        console.log("componentDidCatch",error)
    }

    render(){
        return (
            <div>
                <h3>App</h3>
                <button onClick={()=>{
                    this.setState({
                        isShow:!this.state.isShow
                    })
                }}>隐藏Two</button>
                {
                    // this.state.isError?<div>产生了异常</div>:<My/>
                }
                <Three/>

                {
                    this.state.isShow && <Two/>
                }
                {/*<One userName={"zhangsan"}/>*/}
                {/*<Home num={1}/>*/}
                {/*<Home num={2}/>*/}
                {/*<Home num={3}/>*/}
                {/*<Home num={4}/>*/}
                {/*<Home num={5}/>*/}
                {/*<Home num={6}/>*/}
                {/*<Home num={7}/>*/}
            </div>
        );
    }

}

export default App;